/**
 * Copyright (c) 2022 www.talkweb.com.cn Inc. AlL rights reserved.
 */
package com.sky.wsp.mybatis.plus.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.sky.wsp.mybatis.plus.dao.vo.UserOrgVO;
import com.sky.wsp.mybatis.plus.service.IUserJoinOrgService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;


/**
 * 用户表控制器，表关联操作数据库
 *
 * @author wangshaopeng@talkweb.com.cn
 * @Date 2023-01-11
 */
@RestController
@RequestMapping("/user/join/org")
public class UserJoinOrgController {

    @Resource(name = "userJoinOrgServiceImpl")
    private IUserJoinOrgService userJoinOrgService;

    /**
     * 获取用户表分页
     */
    @GetMapping(name = "获取用户表分页", value = "/page")
    public Page<UserOrgVO> findPage(UserOrgVO query) {
        Page<UserOrgVO> page = new Page<>();
        Page<UserOrgVO> result = userJoinOrgService.findPage(query, page);
        return result;
    }

    /**
     * 获取用户表列表
     */
    @GetMapping(name = "获取用户表列表", value = "/list")
    public List<UserOrgVO> findList(UserOrgVO query) {
        List<UserOrgVO> list = userJoinOrgService.findList(query);
        return list;
    }

    /**
     * 用户表详情
     */
    @GetMapping(name = "获取用户表详情", value = "/detail")
    public UserOrgVO detail(Long id) {
        UserOrgVO entity = userJoinOrgService.myFindById(id);
        if(null == entity){
            return new UserOrgVO();
        }
        return entity;
    }

    /**
     * 用户表详情
     */
    @GetMapping(name = "获取用户表详情", value = "/detail-no-tenant")
    public UserOrgVO detailNoTenant(Long id) {
        UserOrgVO entity = userJoinOrgService.myFindByIdNoTenant(id);
        if(null == entity){
            return new UserOrgVO();
        }
        return entity;
    }
}
